#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

#include "string_utilities.h"

/*
 * 
 */
int main(int argc, char** argv)
{
	string s = "  a b   ";
	vector<string> tokens;
	string delim = " ";

	unsigned long n = split(s, tokens, delim);

	cout << "split run : 1" << endl;
	if (n != 2)
	{
		cerr << "split : expected 2 resulting tokens (instead of " << n << ")" << endl;
		return -1;
	}
	if (tokens.at(0) != "a" || tokens.at(1) != "b")
	{
		cerr << "split : tokens don't have the expected result" << endl;
		return -1;
	}
	
	cout << "split run : 2" << endl;
	tokens.clear();
	
	s = "  a-b   ";
	delim = " -";
	n = split(s, tokens, delim);

	if (n != 2)
	{
		cerr << "split : expected 2 resulting tokens (instead of " << n << ")" << endl;
		return -1;
	}
	if (tokens.at(0) != "a" || tokens.at(1) != "b")
	{
		cerr << "split : tokens don't have the expected result" << endl;
		return -1;
	}

	cout << "split test passed" << endl;

	return 0;
}

